﻿namespace Sitecore.ChangesTracker.Commands
{
  using System;
  using Diagnostics;
  using Shell.Applications.WebEdit;
  using Shell.Framework.Commands;
  using Sitecore.Web;
  using Web.UI.Sheer;

  public class PrevStart : Command
  {
    public override void Execute(CommandContext context)
    {
      Assert.ArgumentNotNull(context, "context");
      //WebEditUtil.SetCurrentDate(WebEditUtil.GetCurrentDate().AddDays(-1));
      DateTime current = WebUtil.GetSessionDateTime("cht_sdate", DateTime.Now.Date).AddDays(-1);
      DateTime end = WebUtil.GetSessionDateTime("cht_edate", DateTime.Now.Date);
      if (current > end)
      {
        return;
      }
      WebUtil.SetSessionValue("cht_sdate", current);
      SheerResponse.SetLocation(string.Empty);
    }
  }
}

